package com.ocom.webapi.controller;

import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.entity.card.EntityAd;
import com.ocom.common.resp.Result;
import com.ocom.webapi.feign.PayConfigClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@PreAuthorize("@pms.hasRole('ROLE_WEB')" )
public class AdController {

    @Autowired
    private PayConfigClientService payConfigClientService;

    //新增广告图（addAd）
    @PostMapping(PayConfigUrl.URLP_PayConfig_addAd)
    public Result addAd(@RequestBody EntityAd entityAd){
        return payConfigClientService.addAd(entityAd);
    }

    //删除广告图（delAd）
    @PostMapping(PayConfigUrl.URLP_PayConfig_delAd)
    public Result delAd(@RequestBody EntityAd entityAd){
        return payConfigClientService.delAd(entityAd.getComId(),entityAd.getId());
    }

    @PostMapping(PayConfigUrl.URLP_PayConfig_adList)
    public Result adList(@RequestBody EntityAd entityAd){
        return payConfigClientService.adList(entityAd.getComId(),entityAd.getDeviceType(),entityAd.getType());
    }
}
